# _*_ coding:utf-8 _*_
import json
import random


from utils import readConfig
from utils import httpRequest

readConfigObj = readConfig.ReadConfig("\\testFile\\login.ini")
def getLoginCase(section):
    devicesId = readConfigObj.getConfig(section,"devicesId")
    userName = readConfigObj.getConfig(section, "userName")
    passwd = readConfigObj.getConfig(section, "passwd")
    url = readConfigObj.getConfig(section, "url")
    respect = readConfigObj.getConfig(section, "respect")
    dict = {"devicesId":devicesId,"userName":userName,"passwd":passwd,"url":url,"respect":respect}
    return dict

def loginPost(url,devicesId,userName,passwd):
    httpReq = httpRequest.ConfigHttp()
    httpReq.set_url(url)
    httpReq.set_data(json.dumps({"Device-Id": devicesId, "userName":  userName, "passwd":  passwd,
                        "reqSn": random.randint(1, 99999999)}))
    resp = httpReq.post()
    return resp
